<?php

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Admin Routes
|--------------------------------------------------------------------------
|
| Here is where you can register admin routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "admin" middleware group. Now create something great!
|
*/

Route::group([
    'namespace'=>'Admins',
    'prefix'=>'adminApi',
], function () {
    #第一个版本
    Route::group([
        'prefix'=>'v2',
    ], function () {
        /*
         |-------
         | 管理员（员工）
         |-------
         */
        Route::group([
            'namespace'=>'Admin',
            'middleware' => ['auth:admins','admin'],
        ], function ($router) {
            # 登录
            $router->any('login', 'AdminApiController@login')->withoutMiddleware('auth:admins');
            # 员工身份列表
            $router->post('identityList', 'AdminController@identityList');
            # 选择身份
            $router->post('chooseIdentity', 'AdminController@chooseIdentity');
            # 账号激活
            $router->post('activateAccount', 'AdminController@activateAccount');
            # 通过原密码修改密码
            $router->post('changePassword', 'AdminController@changePassword');
            # 通过短信验证码修改密码
            $router->post('changePasswordUseSmsCode', 'AdminController@changePasswordUseSmsCode');
            # 切换身份
            $router->post('changeIdentity', 'AdminController@changeIdentity');
            # 刷新token
            $router->post('refreshToken', 'AdminController@refreshToken');
            # 登出
            $router->post('logout', 'AdminController@logout');
            # getAdminInfo
            $router->post('getAdminInfo', 'AdminController@getAdminInfo');
        });
        /*
         |-------
         | 菜单
         |-------
         */
        Route::group([
            'namespace'=>'Menu',
            'prefix'=>'menu',
        ], function ($router) {
            # 获取菜单信息--todo：需要和前端沟通后再完善接口和数据表
            $router->post('index', 'MenuController@index');
        });
        /*
         |-------
         | 组织架构与权限
         |-------
         */
        Route::group([
            'namespace'=>'Organization',
            'prefix'=>'organization',
        ], function ($router) {
            $router->any('/',function(){
                return Auth::guard('admins')->user();
            });
            /*
             |-------
             | 组织架构与权限-部门管理
             |-------
             */
            Route::group([
                'prefix'=>'department',
            ], function ($router) {
                # 列表
                $router->post('index', 'DepartmentController@index');
                # 创建
                $router->any('create', 'DepartmentController@create');
                # 更新
                $router->post('update', 'DepartmentController@update');
                # 详情
                $router->post('detail', 'DepartmentController@detail');
                # 删除
                $router->post('delete', 'DepartmentController@delete');
                # 修改状态
                $router->post('changeStatus', 'DepartmentController@changeStatus');
                # 数据恢复
                $router->post('restore', 'DepartmentController@restore');
                # 销毁
                $router->post('destroy', 'DepartmentController@destroy');
            });
            /*
             |-------
             | 组织架构与权限-岗位管理
             |-------
             */
            Route::group([
                'prefix'=>'posts',
            ], function ($router) {
                # 列表
                $router->post('index', 'PostsController@index');
                # 创建
                $router->any('create', 'PostsController@create');
                # 更新
                $router->post('update', 'PostsController@update');
                # 详情
                $router->post('detail', 'PostsController@detail');
                # 删除
                $router->post('delete', 'PostsController@delete');
                # 修改状态
                $router->post('changeStatus', 'PostsController@changeStatus');
                # 数据恢复
                $router->post('restore', 'PostsController@restore');
                # 销毁
                $router->post('destroy', 'PostsController@destroy');
            });
        });
    });
});

